package com.gitee.feizns.explore.data_structure.tree.bs.mid;

/**
 * @author feizns
 * @since 2020/3/10
 */
public class InsertIntoBST {

    public static void main(String[] args) {

    }

    public static TreeNode insertIntoBST(TreeNode root, int val) {
        if ( root != null ) {
            if ( val < root.val )
                root.left = insertIntoBST(root.left, val);
            else if ( val > root.val )
                root.right = insertIntoBST(root.right, val);
            return root;
        }
        return new TreeNode(val);
    }

}
